<template>
  <div class="newInfobar" >
  
      <h5>{{newInfo.title}}</h5>
      <p class="pp">
          <span>发表时间：{{newInfo.add_time | dateFormat}}</span>
          <span>点击{{newInfo.click}} 次</span>
      </p>
      <hr>
      <!-- 内容 -->
      <div v-html="newInfo.content" class="content">
          
      </div>
     <!-- 评论子组件 -->
     <comment-box :id="$route.params.id"></comment-box>
    
  </div>
</template>


<script>
import {Toast} from 'mint-ui'
//导入子组件模板对象
import comment from '../subcomponent/moment.vue'
export default {
    data(){
        return {
            newInfo:{}//存放新闻详情
        }
    },
    created(){
        this.getnew()
    },
    methods:{
        getnew(){
            var id=this.$route.params.id//获取id
            this.$http.get("api/getnew/"+id).then(result =>{
                if(result.body.status===0){
                    //console.log(result.body)
                    this.newInfo=result.body.message[0]
                }
                else{
                    Toast("获取失败")
                }
            })
        }
    },
    components:{
        'comment-box':comment
    }
   
  
}
</script>


<style lang="less"  >
.newInfobar{
    h5{
        font-weight: bold;
        color:red;
        text-align: center;
    }
    .pp{
        color:deepskyblue;
        display:flex;
        justify-content:space-between;
        font-size: 12px;
        padding:0 5px;
    }
    .content{
       
        padding:0 5px;
        img{
            width:100%;
        }
    }
}
</style>

